
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>threadlocal | Typhoon&#39;s code space</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="typhoon">
    

    
    <meta name="description" content="ThreadLocalʵ���̸߳��� ���ճ���̹����У����ǻᾭ�����������������̰߳�ȫ���⣬����ԭ����Ƕ��̶߳�ͬһ��������Ĺ����µģ���û�����л�����������¿���ĳ���̶߳Ա������޸Ĳ������������߳��õ��ı���ֵʧЧ�����ڲ����������õ������Ǽ����������ֹ���">
<meta property="og:type" content="article">
<meta property="og:title" content="threadlocal">
<meta property="og:url" content="http://scorpioaeolus.oschina.io/2018/04/30/threadlocal/index.html">
<meta property="og:site_name" content="Typhoon&#39;s code space">
<meta property="og:description" content="ThreadLocalʵ���̸߳��� ���ճ���̹����У����ǻᾭ�����������������̰߳�ȫ���⣬����ԭ����Ƕ��̶߳�ͬһ��������Ĺ����µģ���û�����л�����������¿���ĳ���̶߳Ա������޸Ĳ������������߳��õ��ı���ֵʧЧ�����ڲ����������õ������Ǽ����������ֹ���">
<meta property="og:updated_time" content="2018-04-30T10:42:31.983Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="threadlocal">
<meta name="twitter:description" content="ThreadLocalʵ���̸߳��� ���ճ���̹����У����ǻᾭ�����������������̰߳�ȫ���⣬����ԭ����Ƕ��̶߳�ͬһ��������Ĺ����µģ���û�����л�����������¿���ĳ���̶߳Ա������޸Ĳ������������߳��õ��ı���ֵʧЧ�����ڲ����������õ������Ǽ����������ֹ���">

    
    <link rel="alternative" href="/atom.xml" title="Typhoon&#39;s code space" type="application/atom+xml">
    
    
    <link rel="icon" href="/typhoon/img/java.png">
    
    
    <link rel="apple-touch-icon" href="/typhoon/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/typhoon/img/jacman.jpg">
    
    <link rel="stylesheet" href="/typhoon/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/typhoon/"><img src="/typhoon/img/java.png" alt="Typhoon&#39;s code space" title="Typhoon&#39;s code space"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/typhoon/" title="Typhoon&#39;s code space">Typhoon&#39;s code space</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/typhoon/">主页</a></li>
					
						<li><a href="/typhoon/archives">归档</a></li>
					
						<li><a href="/typhoon/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="搜索" />
						<input type="hidden" name="q" value="site:scorpioaeolus.oschina.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/typhoon/2018/04/30/threadlocal/" title="threadlocal" itemprop="url">threadlocal</a>
  </h1>
  <p class="article-author">By
       
		<a href="/typhoon/about" title="typhoon" target="_blank" itemprop="author">typhoon</a>
		
  <p class="article-time">
    <time datetime="2018-04-30T10:41:51.000Z" itemprop="datePublished"> 发表于 2018-04-30</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		
			<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#ThreadLocalʵ���̸߳���"><span class="toc-number">1.</span> <span class="toc-text">ThreadLocalʵ���̸߳���</span></a></li></ol>
		
		</div>
		
		<h2 id="ThreadLocalʵ���̸߳���"><a href="#ThreadLocalʵ���̸߳���" class="headerlink" title="ThreadLocalʵ���̸߳���"></a>ThreadLocalʵ���̸߳���</h2><blockquote>
<p>���ճ���̹����У����ǻᾭ�����������������̰߳�ȫ���⣬����ԭ����Ƕ��̶߳�ͬһ��������Ĺ����µģ���û�����л�����������¿���ĳ���̶߳Ա������޸Ĳ������������߳��õ��ı���ֵʧЧ�����ڲ����������õ������Ǽ����������ֹ�������������jvm�����ֲ�ʽ���ȵȣ�Ŀ���޷������̶߳Ա������޸��������߳����л����ʸ��±�����������������³�����������ڸ߷����������»��Ϊ����ƿ�������ǻع�ͷ�������Ƕ�˼��һ�£�����˵ÿ���߳�ӵ��һ�ݱ�������ѯ���²������ڸ��Ե��߳̿ռ���У��̰߳�ȫ����Ҳ�Ͳ������ˡ�����jdk�ṩ��һ�ֻ����̵߳Ĵ洢�ṹThreadLocal���պý�����������⡣</p>
</blockquote>
<p><strong>I  Դ�����</strong><br>  �����ȴ�Դ��������һ��ThreadLocal���ʵ���߳�ֱ�ӵĸ����(ǣ����Thread��ThreadLocal)��<br>  1��<em>Thread</em><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">/* ThreadLocal values pertaining to this thread. This map is maintained</div><div class="line">   * by the ThreadLocal class. */</div><div class="line">  ThreadLocal.ThreadLocalMap threadLocals = null;</div></pre></td></tr></table></figure></p>
<p>�̵߳Ļ���������һ��ThreadLocal.ThreadLocalMap���͵ı�����Ҳ���������������߳����ȵĴ洢�ռ䡣</p>
<p>2��<em>ThreadLocal</em> ������õ���get��set����<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div></pre></td><td class="code"><pre><div class="line"> /**</div><div class="line">   * Returns the value in the current thread&apos;s copy of this</div><div class="line">   * thread-local variable.  If the variable has no value for the</div><div class="line">   * current thread, it is first initialized to the value returned</div><div class="line">   * by an invocation of the &#123;@link #initialValue&#125; method.</div><div class="line">   *</div><div class="line">   * @return the current thread&apos;s value of this thread-local</div><div class="line">   */</div><div class="line">  public T get() &#123;</div><div class="line">      Thread t = Thread.currentThread();</div><div class="line">      ThreadLocalMap map = getMap(t);</div><div class="line">      if (map != null) &#123;</div><div class="line">          ThreadLocalMap.Entry e = map.getEntry(this);</div><div class="line">          if (e != null)</div><div class="line">              return (T)e.value;</div><div class="line">      &#125;</div><div class="line">      return setInitialValue();</div><div class="line">  &#125;</div><div class="line"></div><div class="line">/**</div><div class="line">   * Get the map associated with a ThreadLocal. Overridden in</div><div class="line">   * InheritableThreadLocal.</div><div class="line">   *</div><div class="line">   * @param  t the current thread</div><div class="line">   * @return the map</div><div class="line">   */</div><div class="line">  ThreadLocalMap getMap(Thread t) &#123;</div><div class="line">      return t.threadLocals;</div><div class="line">  &#125;</div><div class="line"></div><div class="line">/**</div><div class="line">   * Sets the current thread&apos;s copy of this thread-local variable</div><div class="line">   * to the specified value.  Most subclasses will have no need to</div><div class="line">   * override this method, relying solely on the &#123;@link #initialValue&#125;</div><div class="line">   * method to set the values of thread-locals.</div><div class="line">   *</div><div class="line">   * @param value the value to be stored in the current thread&apos;s copy of</div><div class="line">   *        this thread-local.</div><div class="line">   */</div><div class="line">  public void set(T value) &#123;</div><div class="line">      Thread t = Thread.currentThread();</div><div class="line">      ThreadLocalMap map = getMap(t);</div><div class="line">      if (map != null)</div><div class="line">          map.set(this, value);</div><div class="line">      else</div><div class="line">          createMap(t, value);</div><div class="line">  &#125;</div><div class="line"></div><div class="line">  /**</div><div class="line">   * Create the map associated with a ThreadLocal. Overridden in</div><div class="line">   * InheritableThreadLocal.</div><div class="line">   *</div><div class="line">   * @param t the current thread</div><div class="line">   * @param firstValue value for the initial entry of the map</div><div class="line">   * @param map the map to store.</div><div class="line">   */</div><div class="line">  void createMap(Thread t, T firstValue) &#123;</div><div class="line">      t.threadLocals = new ThreadLocalMap(this, firstValue);</div><div class="line">  &#125;</div><div class="line"></div><div class="line">  /**</div><div class="line">   * Variant of set() to establish initialValue. Used instead</div><div class="line">   * of set() in case user has overridden the set() method.</div><div class="line">   *</div><div class="line">   * @return the initial value</div><div class="line">   */</div><div class="line">  private T setInitialValue() &#123;</div><div class="line">      T value = initialValue();</div><div class="line">      Thread t = Thread.currentThread();</div><div class="line">      ThreadLocalMap map = getMap(t);</div><div class="line">      if (map != null)</div><div class="line">          map.set(this, value);</div><div class="line">      else</div><div class="line">          createMap(t, value);</div><div class="line">      return value;</div><div class="line">  &#125;</div></pre></td></tr></table></figure></p>
<pre><code>���Կ���������get������ʱ����ȥ��ǰ�̻߳�ȡthreadLocals������(1)���threadLocals�Ѿ���ʼ������ThreadLocalMap��ʹ��ThreadLocal��ѯ������ֵ��(2)���threadLocalsû�г�ʼ��������setInitialValue
</code></pre><p>()�����ؽ����setInitialValue���map��ʼ����ֱ�ӽ���ʼֵ�ŵ�map�У����򴴽�map����ʼ�����ء�</p>
<pre><code>ThreadLocalMapʵ�ֺ�HashMap�������ƣ��˴���������������ɲ���HashMapϵ��Դ�������
</code></pre><p>II ������֤</p>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">


</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://scorpioaeolus.oschina.io/2018/04/30/threadlocal/" data-title="threadlocal | Typhoon&#39;s code space" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 

<div class="next">
<a href="/typhoon/2018/04/21/代理模式/"  title="设计模式----代理模式详解">
 <strong>下一篇：</strong><br/> 
 <span>设计模式----代理模式详解
</span>
</a>
</div>

</nav>

	


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
 
 <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#ThreadLocalʵ���̸߳���"><span class="toc-number">1.</span> <span class="toc-text">ThreadLocalʵ���̸߳���</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">分类</p>
		<ul>
		
		  
			<li><a href="/typhoon/categories/dubbo/" title="dubbo">dubbo<sup>4</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java性能优化/" title="java性能优化">java性能优化<sup>11</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/motan/" title="motan">motan<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/spring/" title="spring">spring<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springmvc/" title="springmvc">springmvc<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/工具/" title="工具">工具<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/性能优化/" title="性能优化">性能优化<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/案例分析/" title="案例分析">案例分析<sup>6</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/缓存/" title="缓存">缓存<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/设计模式/" title="设计模式">设计模式<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/面试题/" title="面试题">面试题<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">标签</p>
		<ul class="clearfix">
		
			
				<li><a href="/typhoon/tags/java性能优化/" title="java性能优化">java性能优化<sup>9</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/性能优化/" title="性能优化">性能优化<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/设计模式/" title="设计模式">设计模式<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/并发/" title="并发">并发<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo过滤器/" title="dubbo过滤器">dubbo过滤器<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo分布式事务/" title="dubbo分布式事务">dubbo分布式事务<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn导出mvn项目/" title="svn导出mvn项目">svn导出mvn项目<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/架构优化/" title="架构优化">架构优化<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/排序性能对比/" title="排序性能对比">排序性能对比<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jsonp跨域请求/" title="jsonp跨域请求">jsonp跨域请求<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/maven/" title="maven">maven<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jdbcTemplate高可用/" title="jdbcTemplate高可用">jdbcTemplate高可用<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/motan使用zk作为注册中心/" title="motan使用zk作为注册中心">motan使用zk作为注册中心<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/spring-redis缓存注解/" title="spring redis缓存注解">spring redis缓存注解<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/motan入门/" title="motan入门">motan入门<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/异常拦截/" title="异常拦截">异常拦截<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/自带图片/" title="自带图片">自带图片<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/PropertyChangeListener/" title="PropertyChangeListener">PropertyChangeListener<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn分支/" title="svn分支">svn分支<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/使用本地缓存/" title="使用本地缓存">使用本地缓存<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">友情链接</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">新浪微博</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m a java coder. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:ScorpioAeolus@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2018 
		
		<a href="/typhoon/about" target="_blank" title="typhoon">typhoon</a>
		
		
		</p>
</div>
</footer>
    <script src="/typhoon/js/jquery-2.0.3.min.js"></script>
<script src="/typhoon/js/jquery.imagesloaded.min.js"></script>
<script src="/typhoon/js/gallery.js"></script>
<script src="/typhoon/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>









<link rel="stylesheet" href="/typhoon/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/typhoon/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="返回顶部"><img src="/typhoon/img/scrollup.png"/></a>
	</div>
	<script src="/typhoon/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
